package example;
import facecat.FaceCatScript;
import facecat.topin.core.*;
import facecat.topin.xml.*;
import facecat.topin.grid.*;
import facecat.topin.tab.*;

/*
* 树形示例
 */
public class TreeExample extends FCUIXml
{
    /*
     * 加载Xml
     * @param fileName 文件名
     * @param view 视图名称
     */
   public void loadXml(String fileName, FCView view)
   {
       setScript(new FaceCatScript(this));
       super.loadXml(fileName, view);
       FCTree tree = getTree("Tree");
       //获取第二页
       FCTabPage tabPage = getTabPage("TabPage2");
       FCTree newTree = new FCTree();
       newTree.setLocation(new FCPoint(50, 50));
       newTree.setSize(new FCSize(200, 400));
       newTree.setHeaderVisible(false);
       tabPage.addView(newTree);

       for (int i = 0; i < 10; i++)
       {
           FCGridColumn column1 = new FCGridColumn();
           column1.setWidth(20);
           newTree.addColumn(column1);
           FCGridColumn column2 = new FCGridColumn();
           column2.setWidth(20);
           newTree.addColumn(column2);
           FCGridColumn column3 = new FCGridColumn();
           column3.setWidth(160);
           newTree.addColumn(column3);
       }
       newTree.update();

       for (int i = 0; i < 3; i++)
       {
           FCTreeNode node =  new FCTreeNode();
           node.setText("Node");
           newTree.appendNode(node);
           for (int j = 0; j < 3; j++)
           {
               FCTreeNode subNode = new FCTreeNode();
               subNode.setText("SubNode");
               node.appendNode(subNode);
               for (int m = 0; m < 3; m++)
               {
                   FCTreeNode sunNode = new FCTreeNode();
                   sunNode.setText("SunNode");
                   subNode.appendNode(sunNode);
               }
           }
       }
       newTree.update();
   }
}